package cre.mybatis;

import org.apache.ibatis.io.Resources;
import org.apache.ibatis.session.Configuration;
import org.apache.ibatis.session.SqlSessionFactory;
import org.apache.ibatis.session.SqlSessionFactoryBuilder;

import java.io.IOException;
import java.io.InputStream;
import java.util.Properties;

/**
 * @Author guchenbo
 * @Date 2019/3/27.
 */
public class MybatisDemo {

    public static void main(String[] args) throws IOException {
        InputStream stream = Resources.getResourceAsStream("mybatis-config.xml");
        Properties properties = new Properties();
        properties.put("jdbc.user", "test2");

        SqlSessionFactoryBuilder builder = new SqlSessionFactoryBuilder();
        SqlSessionFactory sessionFactory = builder.build(stream, properties);
        Configuration configuration = sessionFactory.getConfiguration();

        System.out.println(configuration.getVariables());
    }
}
